package com.itheima.controller.admin;

import com.itheima.DTO.LoginDTO;
import com.itheima.VO.*;
import com.itheima.result.Result;
import com.itheima.service.IndexService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;


@RestController
@Slf4j
@RequestMapping("/index")
@RequiredArgsConstructor
public class IndexController {

    private final IndexService indexService;

    @PostMapping("/login")
    public Result<?> login(@RequestBody LoginDTO loginDTO){
        UserLoginVO userLoginVO = indexService.login(loginDTO);
        return Result.success(userLoginVO);
    }

    @PostMapping("/profile")
    public Result<ProfileVO> profile(){
        ProfileVO profileVO = indexService.profile();
        return Result.success(profileVO);
    }

    @GetMapping("/getConfig")
    public Result<?> getConfig(){
        HashMap<?,?> configVO = indexService.getConfig();
        return Result.success(configVO);
    }

    @GetMapping("/baseInfo")
    public Result<?> baseInfo(){
        BaseInfoVO baseInfoVO = indexService.baseInfo();
        return Result.success(baseInfoVO);
    }
}




